﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
using log4net;
using log4net.Config;
using System.Reflection;

namespace VideoChatClient
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        private static ILog log = LogManager.GetLogger(typeof(App));
        public static ILog Log
        {
            get { return log; }
        }

        static App()
        {
            XmlConfigurator.Configure(new System.IO.FileInfo(@"Log4net.config"));
        }

        static VideoChatClientViewModel viewModel = new VideoChatClientViewModel();
        public static VideoChatClientViewModel ViewModel
        {
            get { return App.viewModel; }
        }

        private void Application_DispatcherUnhandledException(object sender, 
            System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
            Log.Fatal("Processed in DispatcherUnhandledException.", e.Exception);
#if DEBUG
            MessageBox.Show("Приложение быдет закрыто. Подробности можно указаны в файле ClientVideoChatLogger.log", "", MessageBoxButton.OK, MessageBoxImage.Error);            
#endif
            e.Handled = true;
            App.ViewModel.Restart();
        }

        
    }
}
